Skip to content

fix(config): add !rawfile tag to bypass YAML-sniffing on prompt includes - #529

Open
Amir Fathi (AmirF194) wants to merge 1 commit into
microsoft:mainfrom
AmirF194:fix/528-rawfile-tag-yaml-sniffing
Open

Amir Fathi (AmirF194) wants to merge 1 commit into
microsoft:mainfrom
AmirF194:fix/528-rawfile-tag-yaml-sniffing

Conversation

@AmirF194

Copy link
Copy Markdown
Contributor

Fixes the YAML-sniffing trap you described: added a !rawfile tag (your suggested direction 1) that always returns a file's content verbatim, so a prompt file's type can't flip depending on whether its prose happens to parse as YAML.

construct_file_tag's file-reading and cycle-detection logic is now shared through a new _read_included_file helper, used by both !file and !rawfile. !rawfile skips the YAML sub-parse entirely, so it never recurses and doesn't need the nested-include bookkeeping !file has.

Documented it in workflow-syntax.md, including the "an unrelated prose edit flips it" trap, and updated the Jinja-includes note since a !rawfile-loaded prompt gets the same include search root as !file (it keys off isinstance(x, FileString), not which tag produced it).

Didn't touch direction 2 (a targeted error message on the existing !file heuristic). !rawfile is the actual escape hatch, so it seemed like the more useful half to ship first, and it doesn't preclude adding the error message later.

Added tests for both sides: your exact repro (a line ending in : followed by a bulleted list) still trips !file as before, and the same file loaded through !rawfile stays a string. pytest tests/test_config/ passes on the branch (1371 passed, 3 skipped, none related to this). ruff check/format and ty check are clean on the changed file.

Fixes #528

!file parses every included file's content as YAML and returns a dict/list
whenever the sub-parse succeeds structurally. A Markdown prompt whose prose
happens to parse as YAML (a line ending in ':' followed by a '- ' bullet
list) then fails prompt/system_prompt validation, and an unrelated prose
edit can flip a working file across that boundary.

Add !rawfile, which always returns the file's content verbatim. Extract the
shared file-reading and cycle-detection logic into _read_included_file so
both tags use it; !rawfile skips the YAML sub-parse and never recurses.

Fixes microsoft#528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

!file include parses YAML-shaped Markdown prompts as mappings, breaking prompt/system_prompt validation

1 participant